const state = {
	list: [{
			id: 0,
			userid: 10000001,
			show: true,
			address: "福建省泉州市丰泽区东海泰禾广场13栋",
			room: "1208室",
			phone: "18006966022",
		},
		{
			id: 1,
			userid: 10000002,
			show: false,
			address: "福建省泉州市丰泽区东海泰禾广场14栋",
			room: "1209室",
			phone: "13163973999",
		}
	],
	// 菜单
	menu: {
		text: "新品上线好物推荐立即抢好礼",
		info: [{
				id: 0,
				img: "/static/img/icon_09.png",
				text: "我的卡券",
				url: '/pages/user/tickey/index'
			},
			{
				id: 1,
				img: "/static/img/icon_13.png",
				text: "我的积分",
				url: '/pages/user/score/index'
			},
			{
				id: 2,
				img: "/static/img/icon_14.png",
				text: "我的礼品",
				url: '/pages/my/gift/index'
			},
			{
				id: 3,
				img: "/static/img/icon_15.png",
				text: "我的拼团",
				url: '/pages/user/group/index'
			},
		],
	},
	// 底部单元格
	cell_group: [{
			id: 0,
			img: "https://kuaichuang.insunny.cc/temp_img/icon_1.png",
			text: "个人信息",
			url: '/pages/user/info/index'
		},
		{
			id: 1,
			img: "/static/img/icon_17.png",
			text: "我的订单",
			url: '/pages/user/order/index'
		},
		{
			id: 2,
			img: "/static/img/icon_18.png",
			text: "商家入驻",
			url: "/pages/user/seller_check/index"
		}
	],
	info: {
			id: '',
			show: '',
			address: '',
			room: '',
			phone: '',
		},
	data: {
		show: false,
		area: [{}],
		count: 0,
		selectAddress: ['请选择'],
		selectIndex: [],
		nameList: [],
	}	
};

const actions = {
	get_info({
		commit
	}, payload) {
		commit('set_info', payload)
	},
	get_list({commit}, payload) {
		commit('set_list', payload)
	},
	get_editlist({commit}, payload) {
		commit('set_editlist', payload)
	},
	get_data({commit}, payload) {
		commit('set_data',payload)
	}
};

const mutations = {
	set_list(state, payload) {
		state.list.push(payload)
		state.list.sort((a,b)=>{
			return b.show - a.show;
		})
	},
	set_editlist(state, payload) {
		payload.sort((a,b)=>{
			return b.show - a.show;
		})
		state.list = payload;
	},
	set_info(state, payload) {
		state.info = payload;
	},
	set_data(state, payload) {
		for(let key in payload) {
			state.data[key] = payload[key]
		}
	}
	
}
const getters = {

};

export default {
	namespaced: true,
	state,
	getters,
	mutations,
	actions
}
